﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SHJunketingBLL;
using SHJunketingModel;

public partial class Admin_Permissions_PermissionsInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            databind();
        }

    }
    public void databind()
    {
        this.gvview.DataSource = C_PermissionManage.GetAllC_Permissions();
        this.gvview.DataBind();
    }

    protected void gvview_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //光棒效果
            e.Row.Attributes.Add("onmouseover", "a=this.style.backgroundColor;this.style.backgroundColor='#5869B6'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=a");
            //添加删除确认
            ImageButton imgbtn = e.Row.FindControl("ImageButton2") as ImageButton;
            imgbtn.Attributes.Add("onclick", "return confirm('您确认要删除吗？');");
        }
    }
    protected void gvview_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //获取绑定的名称
        string cmd = e.CommandName;
        
        //修改操作^
        if (cmd == "ed")
        {   
            //获取绑定ID
            int id = Convert.ToInt32(e.CommandArgument);
            Response.Redirect("editinfo.aspx?petmissionsid="+id);
        }
        else if (cmd == "de")//删除操作
        {
            //获取绑定ID
            int id = Convert.ToInt32(e.CommandArgument);
            C_PermissionManage.DeleteC_PermissionByPermissionsID(id);
        }
        else if (cmd == "add")//新增操作
        {
            Response.Redirect("AddInfo.aspx");
        }
        databind();
    }
    protected void gvview_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
    //分页
    protected void gvview_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.gvview.PageIndex = e.NewPageIndex;
        databind();
    }
}
